package com.czh.lg42homework.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.czh.lg42homework.mapper.OrderMapper;
import com.czh.lg42homework.model.OrderDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderMapper orderMapper;

    @GetMapping("/add")
    public String add(Integer userId) {
        OrderDO orderDO = new OrderDO();
        orderDO.setDel(false);
        orderDO.setUpdateTime(new Date());
        orderDO.setCreateTime(new Date());
        orderDO.setUserId(userId);
        orderDO.setCompanyId(1);
        orderDO.setPublishUserId(1);
        orderDO.setPositionId(1);
        orderDO.setResumeType(1);
        orderDO.setStatus("WAIT");

        orderMapper.insert(orderDO);

        return "success";
    }

    @GetMapping("/list")
    public List<OrderDO> list(Integer userId) {

        return orderMapper.selectList(Wrappers.<OrderDO>lambdaQuery()
                .eq(OrderDO::getUserId, userId));
    }
}
